package com.toune.villager.adapter

import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Build
import androidx.annotation.RequiresApi
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.toune.villager.R
import com.toune.villager.bean.GoodsTypeBean

class GoodsTypeAdapter(layoutResId: Int, data: MutableList<GoodsTypeBean.RowsBean>?) :
    BaseQuickAdapter<GoodsTypeBean.RowsBean, BaseViewHolder>(layoutResId, data) {
    override fun convert(holder: BaseViewHolder, item: GoodsTypeBean.RowsBean) {
        holder.setText(R.id.nameTv, item.name)
        if (holder.layoutPosition == selectedPos) {
            holder.setBackgroundColor(
                R.id.nameTv,
                context.resources.getColor(R.color.white)
            )
            holder.setTextColor(
                R.id.nameTv,
                context.resources.getColor(R.color.blue)
            )
        } else {
            holder.setBackgroundColor(
                R.id.nameTv,
                context.resources.getColor(R.color.Gray80_25)
            )
            holder.setTextColor(
                R.id.nameTv,
                context.resources.getColor(R.color.black)
            )
        }
    }


    var selectedPos = 0
    fun setSelectPos(position: Int) {
        selectedPos = position
        notifyDataSetChanged()
    }
}
